﻿using AsscerMVCN2512.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AsscerMVCN2512.Controllers
{
    [ActionLoginFiler(IsCheck = false)]
    public class EmpolyInfoController : Controller
    {
        AssetDBEntities1 db = new AssetDBEntities1();

        // GET: EmployInfo
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult strLogin(string name, string pwd)
        {
            EmpolyInfo info = db.EmpolyInfo.Where(x => x.EmpolyName == name && x.EmpolyPwd == pwd).FirstOrDefault();
            if (info != null)
            {
                Session["user"] = info;
                // 记录登录日志
                System.Diagnostics.Debug.WriteLine($"用户登录成功: {info.EmpolyName}, RoleID: {info.RoleID}");

                return Json(new { success = true, message = "登录成功" });
            }
            else
            {
                return Json(new { success = false, message = "用户名或密码错误" });
            }
        }

        public ActionResult LoginProject()
        {
            return View();
        }
    }
}